Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Disable Global Continuation Lists option #16421

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

LinHu2016
Copy link
Contributor

@LinHu2016 LinHu2016 commented Dec 6, 2022

The Continuation Buffers/Lists keep all of "live" Continuation Objects
and be maintained by GC in order to free up the related native structure
and java stacks in case the Continuation Object has not been terminated
normally.

currently the global Virtual Thread List will keep all of unterminated
Continuation Objects traceable, so Continuation Buffers/Lists are not
useful for current case, can disable it by XXgc:disableContinuationList
for saving extra scan.
cycle.

  • new XXgc options
    disableContinuationList,
    enaleContinuationList,
    verifyContinuationList -- (default) verify if there is an exceptional
    case.

Signed-off-by: Lin Hu linhu@ca.ibm.com

@@ -331,7 +331,7 @@ MM_MarkingSchemeRootClearer::scanContinuationObjects(MM_EnvironmentBase *env)
} else {
/* object was not previously marked */
gcEnv->_markJavaStats._continuationCleared += 1;
VM_VMHelpers::cleanupContinuationObject((J9VMThread *)env->getLanguageVMThread(), object);
VM_VMHelpers::cleanupContinuationObject((J9VMThread *)env->getLanguageVMThread(), object, (MM_GCExtensions::verify_continuation_list == _extensions->continuationListOption));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really necessary? wouldn't shouldScanContinuationObjects return false (since the lists are empty)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry, I was hasty... this is about passing verify not about disabling

{
#if JAVA_SPEC_VERSION >= 19
vmThread->javaVM->internalVMFunctions->freeContinuation(vmThread, objectPtr);
if (verifyOnly) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's 'only'. you also have to free it up in verify mode, otherwise there is a leak

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for verify mode usage, we assume there is no case we can free up, so we assert when we find a case to free up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, you are right, I was wrong.
this is GC path only (I was probably thinking we are in a common path, that last unmount uses, too)

vmThread->javaVM->internalVMFunctions->freeContinuation(vmThread, objectPtr);
if (verifyOnly) {
J9VMContinuation *continuation = J9VMJDKINTERNALVMCONTINUATION_VMREF(vmThread, objectPtr);
assert(NULL == continuation);
Copy link
Contributor

@amicic amicic Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't there an API like Assert_VM_true ? or you could not #include it here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding assertion to .hpp might be problematic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can try to move the method to ContinuationHelpers.cpp

we already attempted this move (most of Continuation specific method should not really be here in a generic VM Helpers file) and there were problems, but still, give a thought/try again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a compiling setting problem to reference from subfolder oti to subfolder vm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • we could pass the mode to freeContinuation, but I'm not very much fan of it (since it's shared with VM path of last unmount)
  • since this is GC specific helper, this could (in fact, should) be moved to a GC *.cpp file

Copy link
Contributor

@amicic amicic Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't find a good file to move it to, but so far best is base ObjectAccessBarrier
some others are ObjectModel, modronapi, VMInterfaceAPI, GCExtensions, FinalizerSupport...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably the best is ContinuationObjectList, since this is already the list that we iterate just before calling the cleanup

as part of the move, change the signature, so that you pass Env, and the method itself will fetch VMThread

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should consider moving needScanStacksForContinuation and various related helpers, too, but not at as a part of this change

env->getGCEnvironment()->_continuationObjectBuffer->add(env, object);
if (MM_GCExtensions::disable_continuation_list != MM_GCExtensions::getExtensions(env)->continuationListOption) {
env->getGCEnvironment()->_continuationObjectBuffer->add(env, object);
}
MM_ObjectAllocationInterface *objectAllocation = env->_objectAllocationInterface;
if (NULL != objectAllocation) {
objectAllocation->getAllocationStats()->_continuationObjectCount += 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no point in doing this in disable mode

@amicic amicic self-requested a review December 8, 2022 17:47
@@ -337,6 +344,7 @@ class MM_GCExtensions : public MM_GCExtensionsBase {
, minimumFreeSizeForSurvivor(DEFAULT_SURVIVOR_MINIMUM_FREESIZE)
, freeSizeThresholdForSurvivor(DEFAULT_SURVIVOR_THRESHOLD)
, recycleRemainders(true)
, continuationListOption(disable_continuation_list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking if we have time to default to verify mode first for a few nights, and then disable it

@@ -62,3 +62,18 @@ MM_ContinuationObjectList::addAll(MM_EnvironmentBase* env, j9object_t head, j9ob
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env);
extensions->accessBarrier->setContinuationLink(tail, previousHead);
}

void
MM_ContinuationObjectList::cleanupContinuationObject(MM_EnvironmentBase* env, j9object_t objectPtr)
Copy link
Contributor

@amicic amicic Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that this has a context (class scope) we can drop Continuation from the name.
we can also add Native in the name, but up to you. for example:
releaseNativesForObject

env->_markVLHGCStats._continuationCleared += 1;
list->cleanupContinuationObject(env, object);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a static method and called with just a class scope.
like this it gives a false perception that list object is relevant
admittedly, moving this method to this class is not perfect, either

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for changing opinions.... but let's just move it to GCExtensions. we already touched it for the processing mode
in that case, the name of the method should still have 'Continuation'
for example releaseNativesForContinuationObject

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have name like scanContinuationNativeSlots in various collector Java Delegate classes.
this cleanup method is common for all collectors, hence make sense to be in GCExtensions (which is just a global Java Delegate, although it does not have 'Delegate' in its name).
overall, both place (class owner) and method name is indeed consistent with scanContinuationNativeSlots

if (NULL != objectAllocation) {
objectAllocation->getAllocationStats()->_continuationObjectCount += 1;
if (MM_GCExtensions::disable_continuation_list != MM_GCExtensions::getExtensions(env)->continuationListOption) {
MM_EnvironmentBase *env = MM_EnvironmentBase::getEnvironment(vmThread->omrVMThread);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be before 'if'


if (verify_continuation_list == continuationListOption) {
J9VMContinuation *continuation = J9VMJDKINTERNALVMCONTINUATION_VMREF(vmThread, objectPtr);
Assert_MM_true(NULL == continuation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Contributor

@dmitripivkine dmitripivkine Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not add assertions to this .hpp file. We either move helper to .cpp file or create special slow path helper for assertion only in .cpp

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or remove assertion obviously

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no problem keeping it here, but don't know if compiler will have

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have particular concern since this is one of top level *hpp files?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we had this problem in the past. Any place it is included it should have proper assertions setup. Currently we have no assertions in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you be more specific - we have asserts in some other *hpp files

Copy link
Contributor

@dmitripivkine dmitripivkine Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding assertions to .hpp file without proper configuring them in this .hpp file creates hidden assumption (limitation) for environment this method is going to be called - the assertions should be configured there. An attempt to include .h file required for assertions in this file would cause multiple compilation errors across code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's even does not matter where this method with assertion is called but the fact this code should be compiled everywhere it is included

@@ -22,6 +22,7 @@

#if !defined(VMHELPERS_HPP_)
#define VMHELPERS_HPP_
#include <assert.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@dmitripivkine dmitripivkine added the project:loom Used to track Project Loom related work label Dec 12, 2022
@amicic
Copy link
Contributor

amicic commented Dec 12, 2022

update the title (it's not disabled by default anymore)

@dmitripivkine dmitripivkine added comp:vm backport:candidate Possible candidate for a backport to a `0.x.y+1` release labels Dec 12, 2022
J9VMThread *vmThread = (J9VMThread *)env->getLanguageVMThread();

if (verify_continuation_list == continuationListOption) {
J9VMContinuation *continuation = J9VMJDKINTERNALVMCONTINUATION_VMREF(vmThread, objectPtr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

@LinHu2016 LinHu2016 force-pushed the GC_Loom_update2 branch 2 times, most recently from 47d27d4 to d2b0e39 Compare December 12, 2022 20:43
#if JAVA_SPEC_VERSION >= 19
J9VMThread *vmThread = (J9VMThread *)env->getLanguageVMThread();

if (verify_continuation_list == getExtensions(env)->continuationListOption) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, just make it a (non-static) member, then

J9VMContinuation *continuation = J9VMJDKINTERNALVMCONTINUATION_VMREF(vmThread, objectPtr);
Assert_MM_true(NULL == continuation);
} else {
vmThread->javaVM->internalVMFunctions->freeContinuation(vmThread, objectPtr);
Copy link
Contributor

@amicic amicic Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class should really have javaVM cached
interestingly, it has a javaVM() helper (that fetches it from omrVM each time) and it's used a number of times, but should just be a cached value
but let's be consistent at least and get it using javaVM() helper here, as well (of course, requires this to be a non-static member)
in future, if there is really a hot path that uses it, we can easily find them all and replace with a chashed value

The Continuation Buffers/Lists keep all of "live" Continuation Objects
and be maintained by GC in order to free up the related native structure
and java stacks in case the Continuation Object has not been terminated
normally.

currently the global Virtual Thread List will keep all of unterminated
Continuation Objects traceable, so Continuation Buffers/Lists are not
useful for current case, can disable it by XXgc:disableContinuationList
for saving extra scan.
cycle.

- new XXgc options
  disableContinuationList,
  enaleContinuationList,
  verifyContinuationList -- (default) verify if there is an exceptional
  case.

Signed-off-by: Lin Hu <linhu@ca.ibm.com>
@LinHu2016 LinHu2016 changed the title Disable Global Continuation Lists by default Add Disable Global Continuation Lists option Dec 13, 2022
@amicic
Copy link
Contributor

amicic commented Dec 13, 2022

jenkins compile win,aix jdk19

@amicic
Copy link
Contributor

amicic commented Dec 13, 2022

jenkins test sanity xlinux jdk19

@amicic amicic merged commit ec0f0d7 into eclipse-openj9:master Dec 13, 2022
@pshipton pshipton removed the backport:candidate Possible candidate for a backport to a `0.x.y+1` release label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:gc project:loom Used to track Project Loom related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants